public class Rotate2 {

    public void solution(int[][] matrix){
        int length = matrix.length;
        for (int i = 0; i < length/2; i++) {
            int[] temp=matrix[i];
            matrix[i]=matrix[length-1-i];
            matrix[length-1-i]=temp;
        }

        for (int i = 0; i < length; i++) {
            for (int j = i+1; j < length; j++) {
                int temp=matrix[i][j];
                matrix[i][j]=matrix[j][i];
                matrix[j][i]=temp;
            }
        }

    }
}
